package com.atguigu.gmall.realtime.app.dwd;

import java.sql.*;
import java.util.Properties;

public class PhoenixExample {
    public static void main(String args[]) throws Exception {
        Connection conn;
        Properties prop = new Properties();
        Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
        conn = DriverManager.getConnection("jdbc:phoenix:thin:url=http://localhost:8765;serialization=protobuf");
        PreparedStatement ps = null;

        String createSql = "create table if not exists GMALL2021_REALTIME.base_trademark( id varchar primary key ,info.tm_name varchar,info.log_url varchar)";
        try {
            //执行建表语句
            System.out.println(createSql);
            ps = conn.prepareStatement(createSql.toString());
            ps.execute();
            ps.close();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new RuntimeException("建表失败！！！");
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Phoenix 建表失败");
                }
            }
        }
    }
}
